<template>
  <button
    ref="_ref"
    class="vk-button"
    :class="{
      [`vk-button--${type}`]: type,
      [`vk-button--${size}`]: size,
      'is-plain': plain,
      'is-round': round,
      'is-circle': circle,
      'is-disabled': disabled,
      'is-loading': loading
    }"
    :disabled="disabled || loading"
    :autofocus="autofocus"
    :type="nativeType"
  >
    <Icon icon="spinner" spin v-if="loading"></Icon>
    <Icon :icon="icon" v-if="icon"></Icon>
    <span>
      <slot></slot>
    </span>
  </button>
</template>
<!-- <script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'VkButton'
})
</script> -->
<script setup lang="ts">
// import { buttonProps } from './types'
// defineProps(buttonProps)
/**安装marcos 插件支持并配置vite.config.ts和tsconfig.app.json
 * 参考网址：https://vue-macros.dev/guide/bundler-integration.html
 */
import type { ButtonProps } from './types'
import { ref } from 'vue'
import Icon from '../Icon/Icon.vue'
defineOptions({
  name: 'VkButton'
})
withDefaults(defineProps<ButtonProps>(), {
  nativeType: 'button'
})

const _ref = ref<HTMLButtonElement>()
defineExpose({
  ref: _ref
})
</script>

<style>
/* .vk-button {
  --main-bg-color: yellow;
  background-color: var(--main-bg-color);
} */
</style>
